package com.soulkun.smarthome.ui.main.home.adapter

import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.databinding.ObservableArrayList
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.soulkun.smarthome.R
import com.soulkun.smarthome.databinding.AppRecycleItemMainHomeDeviceListBinding
import com.soulkun.smarthome.logic.Constant
import com.soulkun.smarthome.logic.dto.DeviceInfoDTO
import com.soulkun.smarthome.logic.model.DeviceModel
import com.soulkun.smarthome.logic.vo.DeviceInfoVO
import soulkun.library.mvvm.adapter.BaseDataBindingRecyclerViewAdapter
import soulkun.library.utils.logE
import soulkun.library.utils.navigateSafe
import soulkun.library.utils.toast

class AppMainHomeDeviceListAdapter(context: Context, modelList: ObservableArrayList<DeviceInfoVO>, private val onClickListener: (ViewDataBinding) -> View.OnClickListener) :
    BaseDataBindingRecyclerViewAdapter<DeviceInfoVO>(context, modelList) {

    override fun getContentLayoutResId(): Int {
        return R.layout.app_recycle_item_main_home_device_list
    }

    override fun setContentViewHolderCreateListener(binding: ViewDataBinding) {
        (binding as AppRecycleItemMainHomeDeviceListBinding).onClickListener = onClickListener(binding)
    }

    override fun setContentViewHolderBindListener(binding: ViewDataBinding, dataPosition: Int) {
        (binding as AppRecycleItemMainHomeDeviceListBinding).deviceInfoVO = dataList[dataPosition]
    }

}